package active.state.lottery;

import java.util.Random;

public class CanLotteryState implements LotteryState {

    LotteryActivity lotteryActivity;

    public CanLotteryState(LotteryActivity lotteryActivity) {
        this.lotteryActivity = lotteryActivity;
    }

    @Override
    public void deductMoney() {
        System.out.println("已经扣过分了");
    }

    @Override
    public boolean lotteryDraw() {
        System.out.println("您正在抽奖... 请稍等");
        Random random = new Random();
        int i = random.nextInt(5);
        if (i == 0) {
            // 发放奖品
            lotteryActivity.setLotteryState(lotteryActivity.getDispenseState());
            return true;
        } else {
            System.out.println("很遗憾没有中奖..");
            // 不可抽奖
            lotteryActivity.setLotteryState(lotteryActivity.getNoLotteryState());
            return false;
        }
    }

    @Override
    public void dispensePrize() {
        System.out.println("不能发放");
    }
}
